home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
187_01
/
reverse.c
< prev
next >
Wrap
Text File
|
1985-12-29
|
838b
|
25 lines
/*@*****************************************************/
/*@ */
/*@ reverse - reverse a string. Stolen from K & R. */
/*@ Used by itoa, ltoa, utoa, etc. */
/*@ */
/*@ Usage: reverse(string); */
/*@ where string is an ASCIIZ string. */
/*@ */
/*@ Returns a pointer to the string. */
/*@ */
/*@*****************************************************/
char *reverse(s) /* reverse string s in place */
char s[];
{
int c, i, j;
for (i=0, j=strlen(s)-1; i<j; i++, j--) {
c = s[i];
s[i] = s[j];
s[j] = c;
}
return s;
}